/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ControlEscolar.DAOs;


import com.ControlEscolar.Beans.Payment;
import java.util.ArrayList;

/**
 *
 * @author Listico
 */
public class PaymentDAO extends AbstractDAO <Payment> {

    @Override
    public void add(Payment object) throws DAOException {
                String sql = "INSERT INTO payments (Amount,PaymentType,TuitionMonth,PaidSemester,TransactionTime)values("
              
               + object.getAmount()+",\""
               + object.getPaymentType()+"\","
               + object.getTuitionMonth()+","
               + object.getPaidSemester()+","
               + object.getTransactionTime()+");";
              
        try {
            connection.executeUpdate(sql);
        } catch (Exception ex) {
            throw new DAOException();
        }
    }

    @Override
    public int delete(String condition) throws DAOException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int update(Payment object) throws DAOException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public ArrayList<Payment> query() throws DAOException {
         try {
            String sql = "SELECT * FROM payments";
            return connection.executeQuery(sql, Payment.class);

        } catch (Exception ex) {
            ex.printStackTrace();
            throw new DAOException();

        }
    }
}